﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace EFCore.Model
{
    public class CustomerEFLogger : ILogger
    {
        private string _categoryName;
        public CustomerEFLogger(string categoryName) 
        {
            _categoryName = categoryName;
        }

        public IDisposable BeginScope<TState>(TState state)
        {
            return null;
        }

        public bool IsEnabled(LogLevel logLevel)
        {
            return true;
        }

        public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
        {
            Console.WriteLine($"CustomerEFLogger {_categoryName} {logLevel} {eventId} {state} ");
            Console.WriteLine("------------------------");
            Console.WriteLine($"CustomerEFLogger {exception?.Message} ");
            Console.WriteLine("------------------------");
            Console.WriteLine($"CustomerEFLogger {_categoryName} {formatter.Invoke(state, exception)}");
            Console.WriteLine("------------------------");
            Console.WriteLine("{_categoryName} {logLevel} {eventId} {state}");
        }
    }
}
